<?php

	require '../utils/conn.php';
	function uploadToken($uid, $token, $ibtOn, $gmatOn, $greOn) {
		$selectQuery = "SELECT * FROM t_token WHERE u_id=".$uid;
		$result = mysql_query($selectQuery) or die("searh failed：". mysql_error());
		$row = mysql_fetch_array($result);
		$query;
		if(empty($row)) { 
			$query = "INSERT INTO t_token (u_id,token,ibt_on,gmat_on,gre_on) VALUES($uid, '$token', $ibtOn, $gmatOn, $greOn)";
		}
		else {
			$query = "UPDATE t_token SET token='$token', ibt_on=$ibtOn, gmat_on=$gmatOn, gre_on=$greOn WHERE u_id=$uid";
		}
		echo $query;
		mysql_query($query) or die("update failed：". mysql_error());
	}
?>